<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>获得标签元素</title>
        <script type="text/javascript">
        	
		function myFunction(){
        		setTimeout(function(){alert("hello")},3000);
        	}
        function timedText(){
        		var x = document.getElementById("txt");
        		var t1 = setTimeout(function(){x.value="2 seconds"}, 2000);
        		var t2 = setTimeout(function(){x.value="4 seconds"}, 4000);
        		var t3 = setTimeout(function(){x.value="6 seconds"}, 6000)
        	}
        </script>
    </head>
    <body>
        <div id="main">
            <p>DOM 是非常有用的。</p>
            <p>该实例展示<b>getElementsByTagName</b>方法</p>
        </div>
        <script>
            var x = document.getElementById("main");
            var y = x.getElementsByTagName("p")
            document.write('第一个元素: ' + y[0].innerHTML)
        </script>
        <div id="div">
        	<button onclick="myFunction()">点我后，三秒显示提示</button>
        </div>
        
        <form>
        	<input type="button" value="show the time" onclick="timedText()" />
        	<input type="text" id="txt" />
        </form>
    </body>
</html>